<?php
require('inc/set.php');
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理员中心 - 屏蔽IP - <?php echo $web['sitename']; ?><?php echo $web['code_author']; ?></title>
<link rel="stylesheet" type="text/css" href="css/<?php echo $web['cssfile']; ?>/style.css">
<script language="javascript" type="text/javascript">
<!--
function allChoose(v1,v2){
  var a=document.getElementsByName("id[]");
    for(var i=0;i<a.length;i++){ if(a[i].checked==false) a[i].checked=v1; else a[i].checked=v2;
  }
}

function chkIp(form){
  var text=form.ips.value;
  text=text.replace(/^[\r\n]+/,'');
  text=text.replace(/[\r\n]+$/,'');
  text=text.replace(/[\r\n]+/g,"\n");
  text=text.replace(/ /g,'');
  if(!text.match(/\d+\.\d+\.\d+\.(\d+|\-)/)){
    alert('请填有效的IP数据！格式为：*.*.*.*');
    return false;
  }
  var arr=text.split("\n");
  if(arr.length>0){
    for(var i=0; i<arr.length; i++){
	  if(!arr[i].match(/^\d+\.\d+\.\d+\.(\d+|\-)$/)){
        alert('第'+(i+1)+'行请填有效的IP数据！只能数字、.、换行符、-填写。用回车键分开IP，即一行填一个IP');
        return false;
      }
    }
  }
  return true;  
}

-->
</script>
</head>

<body>
<table id="logo" width="100%" border="0" cellspacing="5" cellpadding="0">
  <tr>
    <td id="logo_is"><img src="images/logo.gif" width="200" height="60" alt="<?php echo $web['sitename']; ?> - 欢迎您" /></td>
    <td id="logo_ad">&nbsp;</td>
    <td id="logo_ad2">&nbsp;</td>
  </tr>
</table>
<div id="banner"><b>网站导航</b>　
  <?php require('inc/require/nav.txt'); ?>
</div>
<div class="area">
  <div class="area_title"><img src="css/<?php echo $web['cssfile']; ?>/area_title.gif" align="absmiddle" /> <a href="./">论坛首页</a> &gt; <a href="admin.php">管理员中心</a></div>
</div>
<table class="maintable" height="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="left_menu" valign="top"><?php
require('inc/function/confirm_manager.php');
require('inc/function/user_class.php');
require('inc/function/getarea.php');

if(confirm_manager()){
  $manage='&manage=yes';
  require('inc/menu/admin_left_menu.txt');
  $yes='屏蔽IP';
}

?>
    </td>
    <td width="100" valign="middle" align="right" class="pass"> 》</td>
    <td class="m_r" valign="top"><h4><?php echo $yes; ?>&nbsp;</h4>
        <?php
if(isset($yes)){
  $you=explode('_',$cookie[1]);
  echo '欢迎：'.$cookie[0].' '.user_class(abs($cookie[1])).'<br />
<a href="user.php">用户中心</a> | <a href="run.php?run=user_login&act=logout">退出</a> | 您上次访问是'.$you[1].'<br />
<br />
';

?>
        <form action="run.php?run=admin_del&amp;dataname=data/ip" method="post" name="manageform" id="manageform">
          <div class="re_author">屏蔽记录</div>
          <table width="100%" border="0" cellspacing="0" cellpadding="0" class="list">
            <tr>
              <th width="20">&nbsp;</th>
              <th width="*">IP地址</th>
              <th width="150">屏蔽时间</th>
            </tr>
          </table>
          <?php


  require('inc/function/get_page.php');
  if($ips=@glob('./data/ip/*')){
    $n=count($ips); //总记录数
    $p=get_page($n); //页数
    $step=0;
    $seek=$n-$web['pagesize']*($p-1);
    $end=$seek-$web['pagesize']>0?$seek-$web['pagesize']:0;
    for($i=$seek-1;$i>=$end;$i--){
      $ip=basename($ips[$i]);
	  $step++;
      $text.='
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="list">
  <tr class="step'.($step%2).'">
    <td width="20"><input name="id[]" id="id[]" class="" type="checkbox" value="'.$ip.'" /></td>
    <td width="*">'.$ip.'</td>
    <td width="150" align="center">'.gmdate('Y/m/d H:i:s',@filemtime($ips[$i])+(floatval($web['time_pos'])*3600)).'</td>
  </tr>
</table>';
      $ip=NULL;
    }
  }

  if(!empty($text)){
    echo $text;
    echo get_page_foot($p,$n,'');
	echo '  <a href="void(0)" onclick="javascript:allChoose(true,true);return false;">全选</a>-
  <a href="void(0)" onclick="javascript:allChoose(true,false);return false;">反选</a>-
  <a href="void(0)" onclick="javascript:allChoose(false,false);return false;">不选</a>
<input type="submit" name="act" value="删除" />';
  }else{
    echo '<img src="images/i.gif" /> IP数据为空或数据库连接未成功！';
  }
?>
        </form>
      <br />
        <br />
        <br />
        <br />
        <form action="run.php?run=admin_ip" method="post" name="manageform2" id="manageform2" onsubmit="return chkIp(this)">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="300"><textarea name="ips" id="ips" cols="30" rows="10"></textarea></td>
              <td>添加要屏蔽的IP，如100.200.300.400。一行添一个。<br />
                如要屏蔽IP段请填：100.200.300.-<br />
                <br />
                <br />
                <br />
                <input type="submit" name="act" value="提交" /> <input type="reset" name="reset" value="重置" /></td>
            </tr>
          </table>
        </form>
      <?php

}else{
  echo '<img src="images/i.gif" /> 请以基本管理员'.$web['manager'].'<a href="user_login.php?'.basename($_SERVER['REQUEST_URI']).'"><b>登录</b></a>，以获得管理权限';
}

?>
    </td>
  </tr>
</table>
<div id="foot">
  <?php require('inc/require/foot.txt'); ?>
</div>
</body>
</html>
